# 读取模块
import xlrd
# 写入模块
import xlwt
def case1():
    # 文件列表
    xlxs_list = ["1/11.xlsx","1/12.xlsx","1/13.xlsx"]
    # 创建合并后的文件
    workbook = xlwt.Workbook(encoding='ascii')
    worksheet = workbook.add_sheet('Sheet1')
    # 行数
    count = 0
    #表头（只写入第一个xlsx的表头）
    bt = 0
    for name in xlxs_list:
        wb = xlrd.open_workbook(name)
        #按工作簿定位工作表
        sh = wb.sheet_by_name('Sheet1')
        #遍历excel，打印所有数据
        if count>1:
            bt=1
        for i in range(bt,sh.nrows):
            k = sh.row_values(i)
            # 遍历每一行中的每一列
            for j in range(0,len(k)):
                worksheet.write(count,j, label=str(k[j]))
            count = count +1
    workbook.save('1/合并1_辰哥.xlsx')

def case2():
    # 文件列表
    xlxs_list = ["2/21.xlsx","2/22.xlsx","2/23.xlsx"]
    # 创建合并后的文件
    workbook = xlwt.Workbook(encoding='ascii')
    worksheet = workbook.add_sheet('Sheet1')
    # 列数
    col = 0
    for name in xlxs_list:
        wb = xlrd.open_workbook(name)
        #按工作簿定位工作表
        sh = wb.sheet_by_name('Sheet1')
        #遍历excel，打印所有数据

        for i in range(0,sh.nrows):
            k = sh.row_values(i)
            # 遍历每一行中的每一列
            for j in range(0,len(k)):
                worksheet.write(i,col+j, label=str(k[j]))
        col = col +len(k)
    workbook.save('2/合并2_辰哥.xlsx')

def case3():
    # 创建合并后的文件
    workbook = xlwt.Workbook(encoding='ascii')
    worksheet = workbook.add_sheet('Sheet1')
    wb = xlrd.open_workbook("3/31.xlsx")

    sheet_list = ['Sheet1','Sheet2','Sheet3']
    # 行数
    count = 0
    # 表头（只写入第一个xlsx的表头）
    bt = 0
    for st in sheet_list:
        #按工作簿定位工作表
        sh = wb.sheet_by_name(st)
        #遍历excel，打印所有数据
        if count > 1:
            bt = 1
        for i in range(bt, sh.nrows):
            k = sh.row_values(i)
            # 遍历每一行中的每一列
            for j in range(0, len(k)):
                worksheet.write(count, j, label=str(k[j]))
            count = count + 1
    workbook.save('3/合并3_辰哥.xlsx')

